package video

import (
	"common/mildware"
	"common/router"
	"github.com/gin-gonic/gin"
	"video/pkg/dao/mysql"
	"video/pkg/dao/redis"
)

type VRouter struct {
}
type VHandler struct {
	M mysql.Mysql
	R redis.Redis
}

func NewVHandler() VHandler {
	return VHandler{
		M: mysql.NewMysql(),
		R: redis.NewRedis(),
	}
}
func init() {
	router.AddRouter(new(VRouter))
}
func (VRouter) Router(e *gin.Engine) {
	handler := NewVHandler()
	video := e.Group("/v1/video")
	video.GET("/down", handler.DownVideo)
	video.POST("/search/name", handler.SearchLikeByName)
	video.POST("/random/type", handler.GetRandomVideo)
	video.POST("/info/one", handler.GetVideoInfoBase)
	video.Use(mildware.JWTAuthMiddleware())
	video.GET("/search/author", handler.GetAuthorUpVide)
	video.POST("/up", handler.UpVideo)
	video.POST("/delete", handler.DeleteVide)
	video.POST("/update/like", handler.videoLikeOrNo)
}
